<!--智能回复-->
{include file="public/header"}
<div class="content">
<div class="page-inner">
<div class="row">
<div class="col-md-12">
<div class="card">
	<div class="card-header">
		<h4 class="card-title">按钮回复设置<sub>&nbsp;&nbsp;(根据回复进行设置)</sub></h4>
		
		<br>
		 <a style="color:red;margin-left:5px;">示例图：</a>
	    <img src="__STATIC__/img/btn.png" width="320px">
	</div>
	<div class="form-group">
	    <form>
	    <div style="width:180px;">
		<label for="defaultSelect">选择类型</label>
		<select class="form-control form-control" id="type">
		    <option value="0">内联</option>
		    <option value="1">跳转</option>
		</select>
		</div>
		<br>
		
    	<label for="successInput">按钮名称</label>
    	<input type="text" id="text" value="" class="form-control" placeholder="按钮显示的文字" >		
		
        <br>
        <label for="successInput">按钮命令</label>
    	<input type="text" id="cmd" value="" class="form-control" placeholder="即点击按钮后触发的回复内容的命令，或者是外部url">		
		<br>
        </form>
        		<button type="submit" onclick="add_api()" class="btn btn-success">保存</button>
	</div>



	
</div>
</div>
</div>
</div>
</div>

{include file="public/footer"}

<script>


    function IsNull(str) {
    	return (Trim(str) == "") ? false : true;
    }
    function Trim(str) {
    	return str.replace(/(^\s*)|(\s*$)/g, "");
    }
    function replaceHTML(str){
      str = str.replace(/<[^>].*?>/g,"");
      str = str.replace(/&nbsp;/g,"");
      return str;
    }

    function add_api(){
        
        var type = $('#type').val();
        var text = $('#text').val();
        var cmd = $.trim($('#cmd').val());
        
        if(!text || !cmd  ){
               $.notify({
                	icon: 'flaticon-alarm-1',
                	title: '操作提示',
                	message: '请填写关键词',
                },{
                	type: 'info',
                	placement: {
                		from: "bottom",
                		align: "right"
                	},
                	time: 1000,
                });
              return;
        }
        
      
        
        $.post('/add_btn',{'type':type,'text':text,'cmd':cmd},function(res){
            if(res.code>0){
                $.notify({
                	icon: 'flaticon-alarm-1',
                	title: '操作提示',
                	message: res.msg,
                },{
                	type: 'info',
                	placement: {
                		from: "bottom",
                		align: "right"
                	},
                	time: 1000,
                });
            }else{

               $.notify({
                	icon: 'flaticon-alarm-1',
                	title: '操作提示',
                	message: res.msg,
                },{
                	type: 'info',
                	placement: {
                		from: "bottom",
                		align: "right"
                	},
                	time: 1000,
                });
                setTimeout(function(){location.reload()},800);
            }
        },'json');
        
    }
</script>